/**
*┌──────────────────────────────────────────────────────────────┐
*│　描    述：接口实现                                                    
*│　作    者：zzc                                            
*│　版    本：1.0    模板代码自动生成                                                
*│　创建时间：2019-01-04 09:55:38                             
*└──────────────────────────────────────────────────────────────┘
*┌──────────────────────────────────────────────────────────────┐
*│　命名空间： BestTrader.Cms.Repository.SqlServer                                  
*│　类    名： ManagerDataRepository                                      
*└──────────────────────────────────────────────────────────────┘
*/
using BestTrader.Cms.Core.DbHelper;
using BestTrader.Cms.Core.Options;
using BestTrader.Cms.Core.Repository;
using BestTrader.Cms.IRepository;
using BestTrader.Cms.Models;
using Dapper;
using Microsoft.Extensions.Options;
using System;

namespace BestTrader.Cms.Repository.SqlServer
{
    public class ManagerBankCardRepository : BaseRepository<ManagerBankCard, Int32>, IManagerBankCardRepository
    {

        public ManagerBankCardRepository(IOptionsSnapshot<DbOption> options)
        {
            _dbOption = options.Get("BT.TEST");
            if (_dbOption == null)
            {
                throw new ArgumentNullException(nameof(DbOption));
            }
            _dbConnection = ConnectionFactory.CreateConnection(_dbOption.DbType, _dbOption.ConnectionString);
        }

        /// <summary>
        /// 获取用户银行卡
        /// </summary>
        /// <param name="UserId"></param>
        /// <returns></returns>
        public ManagerBankCard GetManagerBankCardByManagerId(int UserId)
        {
            string sql = "select * from [dbo].[ManagerBankCard] where ManagerId=@ManagerId and IsDelete=0";
            return _dbConnection.QueryFirstOrDefault<ManagerBankCard>(sql, new
            {
                ManagerId = UserId,
            });
        }


    }
}